<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <span v-red="color">{{count}}</span>
        <button @click="add">+</button>
        <hr>
        <author></author>
        <hr>
        <p>{{obj.num}}</p>
    </div>
    <script>
        //自定义指令
        Vue.directive('red',function(el,bind,vnode){
            // console.log(el,bind,vnode);
            el.style = `color:${bind.value}`
        })

        //构造起的延伸（自定义标签）
        var author = Vue.extend({
            template:"<p>yjq</p>"
        })
        new author().$mount('author')

        //set 修改数据源
        


        var app = new Vue({
            el:'#app',
            data:{
                count:0,
                color:'red',
                obj:{}
            },
            methods:{
                add(){
                    this.count++
                }
            },
            created() {
                this.$set(this.obj,'num',1) //往数据源添加num属性，和值
            }
        });
    </script>
</body>
</html>